package com.example.chcrm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.chcrm.entity.common.ResponseMsg;
import com.example.chcrm.entity.consignor.CustomerType;
import com.example.chcrm.entity.employee.RoleModels;
import com.example.chcrm.service.CustomerTypeService;
import com.example.chcrm.service.RoleModelsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 邹
 * @Date 2025/4/20 0:21
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/customerType")
@CrossOrigin // 允许跨域访问
public class CustomerTypeController {
    @Autowired
    CustomerTypeService customerTypeService;

    /**
     * 查询所有角色
     *
     * essEmployee
     * @return
     */
    @GetMapping("/selectAllCustomerType")
    public ResponseMsg<Object> selectAllCustomer() {
        return customerTypeService.selectAllCustomerType();
    }

    /**
     * 查询委托商类型
     *
     * essEmployee
     * @return
     */
    @PostMapping("/pageList")
    public ResponseMsg<IPage<RoleModels>> pageList(@RequestBody CustomerType customerType) {
        return customerTypeService.pageList(customerType);
    }

    /**
     * 委托商类型新增
     */
    @PostMapping("/add")
    public ResponseMsg<Object> add(@RequestBody CustomerType roleModels) {

        return  customerTypeService.add(roleModels);
    }

    /**
     * 委托商类型禁用/启用
     */
    @PostMapping("/disable")
    public ResponseMsg<Object> disable(@RequestBody CustomerType roleModels) {

        return  customerTypeService.disable(roleModels);
    }


    /**
     * 委托商类型修改
     */
    @PostMapping("/update")
    public ResponseMsg<Object> update(@RequestBody CustomerType roleModels) {
        return  customerTypeService.update(roleModels);
    }

    /**
     * 委托商类型删除
     */
    @GetMapping("/delete/{id}")
    public ResponseMsg<Object> delete(@PathVariable String id) {
        ResponseMsg<Object> msg = new ResponseMsg<>();
        if (id == null || id.equals("")) {
            msg.fail("删除失败ID不能为空");
            return msg;
        }
        return customerTypeService.delete(id);
    }
}
